#!/usr/bin/env python3

# -*- coding: utf-8 -*-

# @author: zhangbo

# @time: 2025/3/6 16:56

from base.LoginBase import LoginBase
from common.ObjectMap import ObjectMap

from selenium.webdriver.common.by import By


class LoginPage(LoginBase):

    def login_account_input_value(self, driver):
        """
        登录页面输入值
        :param driver:
        :return:
        """
        account_input, account_name = self.login_account_input()
        return ObjectMap().get_element(driver=driver, location_type=By.XPATH,
                                       location_value=account_input).send_keys(account_name)

    def login_password_input_value(self, driver):
        """
        登录页面输入值
        :param driver:
        :return:
        """
        pass_input, pass_name = self.login_password_input()
        return ObjectMap().get_element(driver=driver, location_type=By.XPATH,
                                       location_value=pass_input).send_keys(pass_name)

    def login_button_click(self, driver):
        """
        登录按钮点击
        :param driver:
        :return:
        """
        button_xpath = self.login_button()
        return ObjectMap().get_element(driver=driver, location_type=By.XPATH,
                                       location_value=button_xpath).click()

    def login_assert(self, driver, img_name):
        """
        登录截图断言
        :param driver: 驱动
        :param img_name: 图片名字
        :return:
        """
        return ObjectMap().find_img_in_source(driver, img_name)
